# -*-coding:utf-8-*-
# ProjectName: smart-water-iot-test
# FileName: randomUtil.py
# @DateTime :2023/3/2 17:29
# @Author :
# @Description:�����������
import math
import random


def random_int(star: int, end: int):
    return random.randint(star, end)


def random_folat(star: int, end: int, setp: float = 0.5):
    if setp == 0.5:
        randomNum = random.uniform(star, end).__round__(1)
        deci, integer = math.modf(randomNum)
        deci.__round__(1)
        if deci < setp:
            deci = setp
        elif deci > setp:
            deci = setp
            integer += 1
        else:
            deci = setp
        num = integer + deci
        if num > end:
            num = end
        return num
    else:
        return random.randint(star, end)


if __name__ == '__main__':
    print(random_folat(1, 2, 0.5))
